package cn.lili.controller.grab;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.grab.dingdong.res.adjunct.AreaRequest;
import cn.lili.modules.grab.dingdong.res.adjunct.RegionAllRequest;
import cn.lili.modules.grab.dingdong.res.after.*;
import cn.lili.modules.grab.dingdong.res.goods.*;
import cn.lili.modules.grab.dingdong.res.order.CreateOrderRequest;
import cn.lili.modules.grab.dingdong.res.order.FreightCalcRequest;
import cn.lili.modules.grab.dingdong.res.order.GetOrderInfoRequest;
import cn.lili.modules.grab.dingdong.service.DingdongAdjunctService;
import cn.lili.modules.grab.dingdong.service.DingdongAfterService;
import cn.lili.modules.grab.dingdong.service.DingdongGoodsService;
import cn.lili.modules.grab.dingdong.service.DingdongOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(tags = "企叮咚-接口对接--供调试使用")
@RequiredArgsConstructor
@RequestMapping("/goods/grab/dingdong")
public class DingdongController {

    @Resource
    private DingdongGoodsService dingdongGoodsService;
    @Resource
    private DingdongOrderService dingdongOrderService;
    @Resource
    private DingdongAdjunctService dingdongAdjunctService;
    @Resource
    private DingdongAfterService dingdongAfterService;

    /***************************************************商品相关接口*******************************************************/
    @ApiOperation(value = "商品列表")
    @PostMapping(value = "/goodsList")
    public ResultMessage<Object> goodsList(@RequestBody GoodsQueryRequest goodsQueryRequest) {
        return ResultUtil.data(dingdongGoodsService.goodsList(goodsQueryRequest));
    }

    @ApiOperation(value = "商品分类")
    @PostMapping(value = "/goodsCate")
    public ResultMessage<Object> goodsCate(@RequestBody GoodsCateRequest goodsCateRequest) {
        return ResultUtil.data(dingdongGoodsService.goodsCate(goodsCateRequest));
    }

    @ApiOperation(value = "商品详情")
    @PostMapping(value = "/detail")
    public ResultMessage<Object> detail(@RequestBody DetailRequest detailRequest) {
        return ResultUtil.data(dingdongGoodsService.detail(detailRequest));
    }

    @ApiOperation(value = "商品配送方式")
    @PostMapping(value = "/getYfMode")
    public ResultMessage<Object> getYfMode(@RequestBody GetYfModeRequest retYfModeRequest) {
        return ResultUtil.data(dingdongGoodsService.getYfMode(retYfModeRequest));
    }

    @ApiOperation(value = "商品品牌列表")
    @PostMapping(value = "/getBrand")
    public ResultMessage<Object> getBrand(@RequestBody GetBrandRequest getBrandRequest) {
        return ResultUtil.data(dingdongGoodsService.getBrand(getBrandRequest));
    }

    @ApiOperation(value = "商品库存查询")
    @PostMapping(value = "/getGoodsStock")
    public ResultMessage<Object> getGoodsStock(@RequestBody GetGoodsStockRequest getGoodsStockRequest) {
        return ResultUtil.data(dingdongGoodsService.getGoodsStock(getGoodsStockRequest));
    }

    @ApiOperation(value = "新版商品列表接口（带总数）")
    @PostMapping(value = "/goodsList_v1")
    public ResultMessage<Object> goodsList_v1(@RequestBody GoodsListV1Request goodsListV1Request) {
        return ResultUtil.data(dingdongGoodsService.goodsList_v1(goodsListV1Request));
    }

    @ApiOperation(value = "商品库存查询")
    @PostMapping(value = "/getGoodsStock_v1")
    public ResultMessage<Object> getGoodsStock_v1(@RequestBody GetGoodsStockV1Request getGoodsStockV1Request) {
        return ResultUtil.data(dingdongGoodsService.getGoodsStock_v1(getGoodsStockV1Request));
    }


    /***************************************************订单相关接口*******************************************************/
    @ApiOperation(value = "运费计算")
    @PostMapping(value = "/freightCalc")
    public ResultMessage<Object> freightCalc(@RequestBody FreightCalcRequest freightCalcRequest) {
        return ResultUtil.data(dingdongOrderService.freightCalc(freightCalcRequest));
    }

    @ApiOperation(value = "创建订单")
    @PostMapping(value = "/createOrder")
    public ResultMessage<Object> createOrder(@RequestBody CreateOrderRequest createOrderRequest) {
        return ResultUtil.data(dingdongOrderService.createOrder(createOrderRequest));
    }

    @ApiOperation(value = "订单详情")
    @PostMapping(value = "/getOrderInfo")
    public ResultMessage<Object> getOrderInfo(@RequestBody GetOrderInfoRequest getOrderInfoRequest) {
        return ResultUtil.data(dingdongOrderService.getOrderInfo(getOrderInfoRequest));
    }

    /***************************************************辅助相关接口*******************************************************/
    @ApiOperation(value = "地址查询")
    @PostMapping(value = "/area")
    public ResultMessage<Object> area(@RequestBody AreaRequest areaRequest) {
        return ResultUtil.data(dingdongAdjunctService.area(areaRequest));
    }

    @ApiOperation(value = "获取全部省市区")
    @PostMapping(value = "/regionAll")
    public ResultMessage<Object> regionAll(@RequestBody RegionAllRequest regionAllRequest) {
        return ResultUtil.data(dingdongAdjunctService.regionAll(regionAllRequest));
    }

    /***************************************************售后相关接口*******************************************************/
    @ApiOperation(value = "售后服务列表")
    @PostMapping(value = "/serviceList")
    public ResultMessage<Object> serviceList(@RequestBody ServiceListRequest serviceListRequest) {
        return ResultUtil.data(dingdongAfterService.serviceList(serviceListRequest));
    }

    @ApiOperation(value = "售后服务类型")
    @PostMapping(value = "/serviceTypeList")
    public ResultMessage<Object> serviceTypeList(@RequestBody ServiceTypeListRequest serviceTypeListRequest) {
        return ResultUtil.data(dingdongAfterService.serviceTypeList(serviceTypeListRequest));
    }

    @ApiOperation(value = "创建售后服务")
    @PostMapping(value = "/createService")
    public ResultMessage<Object> createService(@RequestBody CreateServiceRequest createServiceRequest) {
        return ResultUtil.data(dingdongAfterService.createService(createServiceRequest));
    }

    @ApiOperation(value = "售后服务详情")
    @PostMapping(value = "/serviceDetail")
    public ResultMessage<Object> serviceDetail(@RequestBody ServiceDetailRequest serviceDetailRequest) {
        return ResultUtil.data(dingdongAfterService.serviceDetail(serviceDetailRequest));
    }

    @ApiOperation(value = "取消售后服务")
    @PostMapping(value = "/serviceCancel")
    public ResultMessage<Object> serviceCancel(@RequestBody ServiceCancelRequest serviceDetailRequest) {
        return ResultUtil.data(dingdongAfterService.serviceCancel(serviceDetailRequest));
    }

    @ApiOperation(value = "上传售后图片")
    @PostMapping(value = "/uploadResource")
    public ResultMessage<Object> uploadResource(@RequestBody UploadResourceRequest uploadResourceRequest) {
        return ResultUtil.data(dingdongAfterService.uploadResource(uploadResourceRequest));
    }

    @ApiOperation(value = "售后申请单详情")
    @PostMapping(value = "/getOrderRefundInfo")
    public ResultMessage<Object> getOrderRefundInfo(@RequestBody GetOrderRefundInfoRequest getOrderRefundInfoRequest) {
        return ResultUtil.data(dingdongAfterService.getOrderRefundInfo(getOrderRefundInfoRequest));
    }
}
